<template>
<el-row>
    <el-row>
    <!--新增/编辑界面 AqQuestion 问题表-->
        <el-form :model="editForm"  label-width="120px" :rules="editFormRules" ref="editFormRef"> 
            <el-form-item label="标题" prop="title">
                <el-input show-style="origin" v-model="editForm.title" placeholder="标题" :maxlength="50" @change="editSomeFields(editForm,'title',$event)" :disabled="disabledJudge('title')"/>
            </el-form-item> 
            <el-form-item label="问题内容" prop="askContext">
                <editor v-if="visible" v-model="editForm.askContext" auto-complete="off" @change="editSomeFields(editForm,'askContext',$event)"></editor> 
             </el-form-item>
            <el-form-item label="分类" prop="categoryId">
                <mdp-select item-code="aqCategory" show-style="origin" v-model="editForm.categoryId" placeholder="分类" :maxlength="50" @change="editSomeFields(editForm,'categoryId',$event)" :disabled="disabledJudge('categoryId')"/>
            </el-form-item> 
            <el-form-item label="咨询人员名称" prop="askUsername">
                <el-input show-style="origin" v-model="editForm.askUsername" placeholder="咨询人员名称" :maxlength="50" @change="editSomeFields(editForm,'askUsername',$event)" :disabled="disabledJudge('askUsername')"/>
            </el-form-item>
            <el-form-item label="咨询人员手机号" prop="askPhone">
                <el-input show-style="origin" v-model="editForm.askPhone" placeholder="咨询人员手机号" :maxlength="50" @change="editSomeFields(editForm,'askPhone',$event)" :disabled="disabledJudge('askPhone')"/>
            </el-form-item>
            <el-form-item label="状态" prop="status">
                <mdp-select item-code="aqStatus" show-style="origin" v-model="editForm.status" placeholder="状态" :maxlength="1" @change="editSomeFields(editForm,'status',$event)" :disabled="disabledJudge('status')||currOpType=='add'"/>
            </el-form-item>
            <el-form-item label="是否常见问题" prop="isFaq">
                <el-input show-style="origin" v-model="editForm.isFaq" placeholder="是否常见问题" :maxlength="1" @change="editSomeFields(editForm,'isFaq',$event)" :disabled="disabledJudge('isFaq')"/>
            </el-form-item>
            <el-form-item label="询问部门" prop="askDeptid">
                <el-input show-style="origin" v-model="editForm.askDeptid" placeholder="询问部门" :maxlength="50" @change="editSomeFields(editForm,'askDeptid',$event)" :disabled="disabledJudge('askDeptid')||true"/>
            </el-form-item>
            <el-form-item label="咨询时间" prop="askDate">
                <el-date-picker type="date" placeholder="选择日期" show-style="origin" v-model="editForm.askDate"  value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd" :disabled="disabledJudge('askDate')||true"></el-date-picker>
            </el-form-item>
            <el-form-item label="机构编号" prop="branchId">
                <el-input show-style="origin" v-model="editForm.branchId" placeholder="机构编号" :maxlength="50" @change="editSomeFields(editForm,'branchId',$event)" :disabled="disabledJudge('branchId')||true"/>
            </el-form-item>

            <el-form-item label="评论" v-if="currOpType!='add'">
                <comments  :question-id="editForm.id" :is-mng="'1'"></comments>	  
            </el-form-item>
            
			
        </el-form>
    </el-row>
    <slot name="footer" :page="this">
        <el-row v-if="showBtn!==false" style="float:right;" class="footer">
            <el-button @click.native="close">关闭</el-button>
            <el-button v-loading="load.edit" type="primary" @click.native="saveSubmit" :disabled="disabledJudge('addBtn') || !checkBtnQx('addBtn',menuDefId) || load.edit">提交</el-button>
        </el-row>
    </slot>
</el-row>
</template>

<script>
import * as AqQuestionApi from '@/api/mdp/arc/aq/aqQuestion';
import { mapGetters } from 'vuex'
import { MdpFormMixin } from '@/components/mdp-ui/mixin/MdpFormMixin.js';
import Editor from '@/components/Tinymce';  

import Comments from '../aqComment/Tree';  
export default {
    name:'aqQuestionForm',
    mixins:[MdpFormMixin],
    components: {
        Editor,Comments,
    },
    computed: {
    },
    props:{
    },
    watch: {
    },
    data() {
        return {
            menuDefId:'',//menu_def.id 菜单表菜单编号，用于按钮权限判断
            pkNames:["id"],//表格主键的java属性名称，驼峰命名，默认为id,支持多主键
            currOpType:'add',//表单 add、edit，所有按钮可动、detail-只看不能操作
            editFormRules: {
                id:[
                //{ required: true, message: '此项必填', trigger: 'change' },
                //{ min: 1,max: 200, message: '长度在1到200之间', trigger: 'change'}
                ]
            },
            editForm: {
                id:'',title:'',categoryId:'',askUserid:'',askPhone:'',askUsername:'',status:'',isFaq:'',askDeptid:'',askDate:'',askContext:'',branchId:''
            },
            //增删改查(含批量)接口
            apis:{
                queryById: AqQuestionApi.queryAqQuestionById,
                add: AqQuestionApi.addAqQuestion,
                edit: AqQuestionApi.editAqQuestion,
                editSomeFields: AqQuestionApi.editSomeFieldsAqQuestion
            }
        }
    },
    methods: {
         //由组件扩展添加其它的初始页面的逻辑(mounted+onOpen都会调用此函数，建议只添加公共逻辑)
         initCurrData(){

         },
        /**
         * 检查参数是否满足调用后台接口的条件
         * @returns true / false
         */
        preParamCheck(params){
            return true;
        },

        /**
          * 设置某个关键词、按钮、输入框禁用 disabledRules['addBtn']=false
          * 判断某个对象是否可编辑 this.disabledJudge('addBtn')==false
          */
        disabledRulesInit(disabledRules){

        },
        /**
         * 对修改的字段进行判断，返回false ,将取消更新数据库,由组件扩展
         * @param {*} row 当前选中的行
         * @param {*} fieldName 修改的字段名
         * @param {*} $event 修改后的值
         * @param {*} params 将要提交服务器的参数
         * @returns true/false 返回false ,将取消更新数据库
         */
        editSomeFieldsCheck(row,fieldName,$event,params){
            params[fieldName]=$event
            return false;
        },
    },
    mounted() {

    }
}

</script>

<style scoped>

</style>